/*
 * @Author: dingyuwen ding_yuwen@163.com
 * @Date: 2023-02-13 14:56:49
 * @LastEditTime: 2023-09-19 16:36:48
 * @LastEditors: DingYuwen 43669762+DingYuwen@users.noreply.github.com
 * @Description:
 */
import { SimpleGrid } from '@chakra-ui/react';

import { useEffect } from 'react';

import userService from '@/api/user.service';
import Code from '@/features/Invitation/Code';
import Commission from '@/features/Invitation/Commission/Commission';
import Records from '@/features/Invitation/RecordsCard/Records';

import { useAppDispatch } from '@/store/hooks';
import { setRecommendInfo } from '@/store/profileSlice';

export default function Invitation() {
  const dispatch = useAppDispatch();
  useEffect(() => {
    // 查询我的邀请，邀请码，佣金，邀请人数，确认中的佣金
    userService
      .getRecommend()
      .then((data) => {
        data.code === 200 && dispatch(setRecommendInfo(data.rt));
      })
      .catch((e) => {
        console.log(e);
      });
  }, [dispatch]);
  return (
    <SimpleGrid
      w="full"
      columns={{ base: 1, md: 3 }}
      spacing={{ base: 5, lg: 8 }}
    >
      <Code />
      <Commission />
      <Records />
    </SimpleGrid>
  );
}
